# _*_ coding: utf-8 _*_
import pygame
from pygame.locals import *
from sys import exit
from random import randint

SCREEN_SIZE = (700, 600)

pygame.init()
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
font = pygame.font.SysFont("华文行楷", 25)
font_height = font.get_linesize()
event_text = 'no event'

while True:

    # poll()和wait()取出一个事件，get()获得事件列表
    event = pygame.event.wait()
    event_text='no event'

    if event.type == QUIT:
        exit()
    if event.type == KEYUP:
        event_text="KEYUP_"+str(event.key)
    if event.type == MOUSEMOTION:
        event_text="MOUSEMOTION_"+str(event.pos)
    # 触发事件，鼠标按下事件触发空格键事件
    if event.type == MOUSEBUTTONDOWN:
        event=pygame.event.Event(KEYUP,{"key": K_SPACE, "mod": 0, "unicode": u''})
        pygame.event.post(event)
    screen.fill(pygame.color.Color("gray"))

    screen.blit(font.render(event_text, True, (randint(0, 255), randint(0, 255), randint(0, 255))),(0,0))
    pygame.display.update()
